﻿
// DiskWriterDlg.h: 头文件
//

#pragma once

#define WM_USER_UPDATE_UI		(WM_USER + 1)

#define UI_SET_PROGRESS_RANGE	1
#define UI_SET_PROGRESS_VALUE	2
#define UI_WRITE_DISK_BEGIN		3
#define UI_WRITE_DISK_FINISH	4

// Thread parameter.
struct Context
{
	CString szFilePath;
	int volumeID;
	int nFileChunkSize;
};

// CDiskWriterDlg 对话框
class CDiskWriterDlg : public CDialogEx
{
// 构造
public:
	CDiskWriterDlg(CWnd* pParent = nullptr);	// 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DISKWRITER_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持

// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	LRESULT OnUpdateUI(WPARAM wParam, LPARAM lParam);
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD dwData);
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnBnClickedButtonWrite();
	afx_msg void OnBnClickedButtonBrowse();

	DECLARE_MESSAGE_MAP()

protected:
	void GetLogicalDevices();
	void SetWriteButtonState();

private:

	// Image file path.
	CString m_szFilePath;

	// Browse file.
	CButton m_buttonBrowse;

	// Device list.
	CComboBox m_comboDevice;

	// Writing progress
	CProgressCtrl m_progress;

	// File chunk size
	CComboBox m_comboChunkSize;

	// Write button
	CButton m_buttonWrite;

	// Be Writting
	BOOL m_bWritting = FALSE;

	// Thread parameter
	Context m_ctx;
};
